package com.gwd.task.repository;

import com.gwd.task.entity.UserGroupEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import javax.transaction.Transactional;
import java.util.List;

/**
 * @author zhiyongming
 * @date 2020/11/9 9:53
 */
@Repository
public interface UserGroupRepository extends JpaRepository<UserGroupEntity, Long> {
    @Transactional
    @Modifying
    @Query(value = "delete from UserGroupEntity u where u.groupId=?1")
    void deleteByGroupId(Long groupId);

    List<UserGroupEntity> findByUserId(Long userId);
}
